//
//  LiveStreamCollectionViewCell.swift
//  live
//
//  Created by melvyn on 2018/8/17.
//  Copyright © 2018 NEET. All rights reserved.
//

import UIKit
import RxSwift
import SnapKit


class LiveStreamCollectionViewCell: UICollectionViewCell {
    
    @IBOutlet weak var thumbnail: UIImageView!
    @IBOutlet weak var titleTextLabel: UILabel!
    @IBOutlet weak var tagTextLabel: UILabel!
    @IBOutlet weak var upNameTextLabel: UILabel!
    @IBOutlet weak var numberOfVisitsTextLabel: UILabel!
    
    var viewModel: LiveStreamViewModel? {
        didSet {
            guard let viewModel = viewModel else { return }
            
            viewModel.thumbnail
                .drive(thumbnail.rx.image)
                .disposed(by: rx.disposeBag)
            
            viewModel.title
                .drive(titleTextLabel.rx.text)
                .disposed(by: rx.disposeBag)
            
            viewModel.tag
                .drive(tagTextLabel.rx.text)
                .disposed(by: rx.disposeBag)
            
            viewModel.up
                .drive(upNameTextLabel.rx.text)
                .disposed(by: rx.disposeBag)
            
            viewModel.numberOfVisits
                .drive(numberOfVisitsTextLabel.rx.text)
                .disposed(by: rx.disposeBag)
        }
    }
    
    /*
     override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {
     setNeedsLayout()
     layoutIfNeeded()
     
     #if swift(>=4.2)
     let height = contentView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).height
     #else
     let height = contentView.systemLayoutSizeFitting(UILayoutFittingCompressedSize).height
     #endif
     
     var newValue = layoutAttributes.frame
     newValue.size = CGSize(width: newValue.width, height: height)
     
     layoutAttributes.frame = newValue
     return layoutAttributes
     }
     */
}
